package com.yeyks.app.controller.base.hotel;

import com.yeyks.common.ajax.AjaxResponseBody;
import com.yeyks.common.convert.DateEditor;
import com.yeyks.commonReference.service.hotel.HotelSearchB2cService;
import com.yeyks.hotel.param.HotelInfoB2cHotelSearchParam;
import com.yeyks.hotel.param.HotelInfoHotelSearchOrderHotelInfoParam;
import com.yeyks.hotel.vo.HotelInfoHotelSearchOrderHotelInfoVo;
import com.yeyks.hotel.vo.HotelInfoHotelSearchVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * @Author fuchangshuai
 * @date 2019/3/26 4:27 PM
 */
@Api(tags = "酒店搜索b2c接口", description = "酒店搜索b2c接口")
@Slf4j
@RestController
@RequestMapping(value = "/app/hotel")
public class HotelSearchB2cController {

    @Autowired
    private HotelSearchB2cService hotelSearchB2cService;

    @InitBinder
    public void initbinder(WebDataBinder webDataBinder) {
        webDataBinder.registerCustomEditor(Date.class, new DateEditor());
    }

    //v3.4
    @ApiOperation(value = "B2C酒店搜索:c:v3.4")
    @RequestMapping(value = "/b2c/hotelSearch", method = RequestMethod.POST)
    public AjaxResponseBody<HotelInfoHotelSearchVo> b2cHotelSearch(@Validated HotelInfoB2cHotelSearchParam param) {
        HotelInfoHotelSearchVo vo = hotelSearchB2cService.b2cHotelSearch(param);
        return AjaxResponseBody.success(vo);
    }

    //v3.4
    @ApiOperation(value = "B2C订单房态信息:v3.4")
    @RequestMapping(value = "/b2c/b2cHotelOrderCalendar", method = RequestMethod.POST)
    public AjaxResponseBody<HotelInfoHotelSearchOrderHotelInfoVo> b2cHotelOrderCalendar(@Validated HotelInfoHotelSearchOrderHotelInfoParam param) {
        HotelInfoHotelSearchOrderHotelInfoVo vo = hotelSearchB2cService.b2cHotelOrderCalendar(param);
        return AjaxResponseBody.success(vo);
    }

}
